<?php

namespace app\admin\controller\facrm\thread;

use app\common\controller\Backend;

/**
 * 线索分类
 *
 * @icon fa fa-circle-o
 */
class Type extends Backend
{

    /**
     * Type模型对象
     * @var \app\admin\model\facrm\thread\Type
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\facrm\thread\Type;

    }



    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if (false === $this->request->isAjax()) {
            return $this->view->fetch();
        }
        //如果发送的来源是 Selectpage，则转发到 Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
        $list = $this->model
            ->where($where)
            ->order($sort, $order)
            ->paginate($limit);

        $result = $list->items();

        foreach ($result as &$key){



        }

        $result = ['total' => $list->total(), 'rows' => $result];
        return json($result);
    }


    public function indexs()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);

        //如果发送的来源是 Selectpage，则转发到 Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
        $list = $this->model
            ->where($where)
            ->order($sort, $order)
            ->paginate($limit);
        $result = $list->items();



        return json($result);
    }

}
